package com.itheima.stock.controller;

import com.itheima.stock.common.domain.*;
import com.itheima.stock.pojo.StockBusiness;

import com.itheima.stock.service.StockService;
import com.itheima.stock.vo.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.management.ImmutableDescriptor;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/quot")
public class StockController {
    @Autowired
    private StockService service;

    @GetMapping("/stockBusiness")
    public R<List<StockBusiness>> findAllBusiness() {
        return service.findAllBusiness();
    }

    @GetMapping("/index/all")
    public R<List<InnerMarketDomain>> innerIndexAll() {
        return service.innerIndexAll();
    }

    @GetMapping("/sector/all")
    public R<List<PlateMarketDomain>> sectorAll() {
        return service.sectorAll();
    }

    @GetMapping("/stock/increase")
    public R<List<InnerMarketDomain>> getStockIncrease() {
        return service.getStockIncrease();
    }

    @GetMapping("/stock/all")
    public R<PageResult> getStockAll(Integer page, Integer pageSize) {
        return service.getStockAll(page, pageSize);
    }

    @GetMapping("/stock/updown/count")
    public R<Map> getStockUpDownCount() {
        return service.getStockUpDownCount();
    }

    @GetMapping("/stock/export")
    public void stockExpor(HttpServletResponse response, Integer page, Integer pageSize) {
        service.exportStockExcel(response, page, pageSize);
    }

    @GetMapping("/stock/tradevol")
    private R<Map> getStockTravolCompare() {
        return service.getStockTravolCompare();
    }

    @GetMapping("/stock/updown")
    public R<Map> getStockUpDown() {
        return service.getStockUpDownScope();
    }

    @GetMapping("/stock/screen/time-sharing")
    public R<List<Timesharing>> getStockRtInfoByCode4EvrMinute(@RequestParam("code") String sotckCode) {
        return service.getStockRtInfoByCode4EvrMinute(sotckCode);
    }
    @GetMapping("/stock/screen/dkline")
    public R<List<Screendkline>> rengetStockRtInfoByCode4EvrMinute(@RequestParam("code") String sotckCode) {
        return service.rengetStockRtInfoByCode4EvrMinute(sotckCode);
    }
    @GetMapping("/stock/screen/weekkline")
    public  R<List<Screendkline>>zhougetStockRtInfoByCode4EvrMinute(@RequestParam("code") String sotckCode){
        return service.zhougetStockRtInfoByCode4EvrMinute(sotckCode);
    }
}